package com.ioidea.room.bean

import androidx.room.TypeConverter
import androidx.room.TypeConverters
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import java.io.Serializable


/**
 * 亮度3暂时用不上 默认0
 */
data class StrategySchedule(
    val time: String,
    val brightness1: Int,
    val brightness2: Int,
    val brightness3: Int = 0
):Serializable

class StrategyScheduleConverters {

    @TypeConverter
    fun stringToObject(value: String): List<StrategySchedule> {
        val listType = object : TypeToken<List<StrategySchedule>>() {

        }.type
        return Gson().fromJson(value, listType)
    }

    @TypeConverter
    fun objectToString(list: List<StrategySchedule>): String {
        val gson = Gson()
        return gson.toJson(list)
    }

}